import * as TYPES from "../action-types";
import _ from "../../utils/utils";

const initial = {
  userInfo: null,
  token: _.storage.get("tk") || "",
};

function userReducer(state = initial, action) {
  state = _.clone(state);
  switch (action.type) {
    case TYPES.SET_TOKEN:
      state.token = action.payload;
      console.log(state, "state");
      break;
    case TYPES.USER_INFO:
      state.userInfo = action.info;
      break;
    default:
  }
  return state;
}

export default userReducer;
